package android_testsuite.mytest.util;

import android.content.Context;
import android.content.SharedPreferences;

/*
 * SharePreference类
 * Created by RenHui on 15-2-9.
 */
public class PreferenceHelper {
    private static final String DEMO = "android_testsuite";   // Preference所属的集合

    private static final String LATEST_IMAGE_URI = "latest_image_uri";  // 最新获取过的照片的路径

    // 获取本应用SharedPreferences的类，获取到此类后才能进行相关的数据操作
    private static SharedPreferences openSharePreferences(Context context) {
        return context.getSharedPreferences(PreferenceHelper.DEMO, Context.MODE_PRIVATE);
    }
    
    // 标签存储测试
    public synchronized static void setImageUri(Context context, String value) {
        openSharePreferences(context).edit().putString(PreferenceHelper.LATEST_IMAGE_URI, value).commit();
    }
    
    // 标签获取测试
    public synchronized static String getImageUri(Context context) {
        return openSharePreferences(context).getString(PreferenceHelper.LATEST_IMAGE_URI, "");
    }
}
